<?php
//So co quan hanh chinh hien thi tren mot trang

$v_limit = CONST_LIMIT_AGENCY_PER_PAGE;
if(isset($_REQUEST['page'])){
	$page=$_REQUEST['page'];
}
else
	$page=1;
if(_is_sqlserver()){
	// Lay so luong co quan hanh chinh
	$cmd = @mssql_init("KM_AF_AgencyCountAll", $conn);
	$result_count_agency = @mssql_execute($cmd);
	$arr_count_agency = _get_row_to_array($result_count_agency);
	@mssql_free_result($result_count_agency);

	$v_total_agency_count =$arr_count_agency['0']['0'];
	$pager  = Pager::getPagerData($v_total_agency_count, $v_limit, $page);
	$page   = $pager->page;
  	$offset = $pager->offset +1; 
  	$limit = $pager->limit;


	//Lay danh sach co quan hanh chinh
	$cmd = @mssql_init("ONEGATE_AF_AgencyGetAll",$conn);
	@mssql_bind($cmd,"@offset", $offset,SQLINT4);	
	@mssql_bind($cmd,"@limit",$limit,SQLINT4);		
	$rs_all_agency = @mssql_execute($cmd);
	$arr_all_agency = _get_row_to_array($rs_all_agency); 
	@mssql_free_result($rs_all_agency);


	//Lay danh sach co quan hanh chinh
/*
	$cmd = @mssql_init("ONEGATE_AF_AgencyGetAll_1",$conn);		
	$rs_all_agency = @mssql_execute($cmd);
	$arr_all_agency = _get_row_to_array($rs_all_agency); 
	@mssql_free_result($rs_all_agency);
	
	//Lay danh sach linh vuc 
	$v_category = CONST_LIMIT_CATE_PER_AGENCY;
	$cmd = @mssql_init("ONEGATE_AF_CateGetByAllAgency",$conn);
	@mssql_bind($cmd,"@p_number", $v_category,SQLINT4);			
	$result = @mssql_execute($cmd);
	//$result_1=mssql_next_result($result);
*/
	
	$v_category = CONST_LIMIT_CATE_PER_AGENCY;
	$cmd = @mssql_init("ONEGATE_AF_CateGetByAllAgency_New",$conn);
	@mssql_bind($cmd,"@offset", $offset,SQLINT4);	
	@mssql_bind($cmd,"@limit",$limit,SQLINT4);	
	@mssql_bind($cmd,"@p_number", $v_category,SQLINT4);			
	$result = @mssql_execute($cmd);
	//$arr_1 = _get_row_to_array($result_1); 
	$arr_all_cate = _get_row_to_array($result); 
	@mssql_free_result($result);

}
?>